Skip to content

Fix Knex transaction errors in prod#162

Merged
SpecialAro merged 3 commits into
ferdium:mainfrom
SpecialAro:knex-trsc-errors
Mar 28, 2026
Merged

Fix Knex transaction errors in prod#162
SpecialAro merged 3 commits into
ferdium:mainfrom
SpecialAro:knex-trsc-errors

Conversation

@SpecialAro
Copy link
Copy Markdown
Member

This commit tries to fix the spam on knex transaction errors not being closed which might be overloading the server CPU. Not sure if this works as it is kind of difficult to test it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce production DB/Knex issues (transaction/connection pool pressure) by adjusting SQLite connection behavior, optimizing “hot path” queries, and adding a functional concurrency regression test.

Changes:

  • Adjust SQLite pool/connection initialization (WAL, synchronous mode, busy timeout) and force a single shared SQLite connection.
  • Add indexes on frequently queried columns in services, workspaces, and tokens.
  • Refactor several endpoints to query Service/Workspace/Token directly (instead of relation queries) and add a concurrency-focused functional test for /user/data.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/functional/dashboard/data.spec.ts Adds a functional test that performs concurrent /user/data requests to catch pool/connection exhaustion regressions.
database/migrations/1774667000000_add_database_hot_path_indexes.ts Adds indexes intended to speed up common lookups and reduce DB load.
config/database.ts Updates SQLite pool sizing and connection PRAGMAs to improve concurrency characteristics and reduce lock contention.
app/Models/User.ts Refactors token lookup/creation to use Token.query() / Token.create() directly.
app/Controllers/Http/WorkspaceController.ts Refactors workspace UUID check and workspace ordering computation (count query), plus orders workspace listing output.
app/Controllers/Http/ServiceController.ts Introduces a shared “load user services” query and minor response shaping refactor.
app/Controllers/Http/Dashboard/ExportController.ts Switches to direct Service/Workspace queries with stable ordering for exports.
app/Controllers/Http/Dashboard/DataController.ts Switches to direct Service/Workspace queries with stable ordering and explicit empty arrays when unauthenticated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/Controllers/Http/WorkspaceController.ts Outdated
Comment thread config/database.ts Outdated
Comment thread config/database.ts Outdated
SpecialAro and others added 2 commits March 28, 2026 04:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SpecialAro SpecialAro merged commit 5d2e274 into ferdium:main Mar 28, 2026
1 check passed
@SpecialAro SpecialAro deleted the knex-trsc-errors branch March 28, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants